<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="format-detection" content="telephone=no">
	<title>群发</title>
	<link href="<?php echo TEMPLATE_SITE_URL;?>/css/qunfa.css" type="text/css" rel="stylesheet">
	<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/zepto.js" charset="utf-8"></script>
</head>
<body>
<div id="pop" class="concernDiv" style="display:none;">
  <div class="concern">
  	<p class="conTitle1" style="font-size:13px;margin-left:1px;" >拍品信息进入群发队列，稍后进行发送</p>
  	<a class="whiteBn know">知道了</a>
  </div>
</div>

<div id="contentbox" style="min-height: 576px;">
			    <div class="topBanner">
			        <div class="send btn">群&nbsp;&nbsp;发</div>
			    </div>

	    		<div class="saleMsgMain">
			        <div class="saleMsgHead">
				            <div class="saleMsgStatic">
				                <span>今日剩余群发消息：<em class="saleMsgNum"><?php echo $output['qunfa_num'];?></em></span>
				            </div>
			            	<div class="saleMsgTips">
			            		多品消息一次能发7个拍品
			            		<a href="<?php echo $output['danpin_link']['value'];?>">单品</a>
			            		<a href="<?php echo $output['duopin_link']['value'];?>">多品</a>
			            	</div>
			        </div>
					
					<?php if(!empty($output['list'])){?>
					<?php foreach($output['list'] as $val){?>
		            <div class="saleList">
		            	<div class="saleItem">
			        		<div class="goodsImg" style="background-image:url(<?php echo UPLOAD_SITE_URL.'/shop/auction/'.$val['auction_add_date'].'/'.$val['auction_img1'];?>);"></div>
			        		<div class="desc"><?php echo bearshop_auction_description_substr($val['auction_description']);?></div>
			        		<div class="endTime"><?php echo date("Y年m月d日",$val['end_time']);?></div>
			                <div class="shareMask" aid="<?php echo $val['id'];?>" open="1" is_share="<?php echo $val['is_share'];?>">
			                	<?php if($val['is_share']!=1){?>			                	
			                	<div class="share">
					                <div class="button" onclick="javascript:location.href='index.php?act=index&auction_id=<?php echo $val['id'];?>';">立即分享</div>
					                <div class="tips">分享拍品后才能群发</div>
					            </div>					            
			                	<?php }else{?>
			                	<div class="unselected"></div>
			                	<?php }?>					            
			        		</div>
		            	</div>
	            	</div>
	            	<?php }?>
	            	<?php }else{?>
	            	<div class="saleList">
		            	<div class="saleItem">
							<p style="margin-top:100px;margin-left:100px;">没有可以发送的拍品</p>
		            	</div>
	            	</div>
	            	<?php }?>
            </div>
</div>

<script type="text/javascript">
	$(function(){

		$('.know').click(function(){
			location.reload();
		});
		
		$('.shareMask').click(function(){	
			var is_share = $(this).attr('is_share');
			if(is_share!='1'){
				return false;
			}
			var open = $(this).attr('open');	
			if(open==1){
				$(this).attr('open','2');
				$(this).children('div').removeClass('unselected');
				$(this).children('div').addClass('selected');
				//var html = '<div class="selected"></div>';
				//$(this).html(html);
			}else{
				$(this).attr('open','1');
				$(this).children('div').removeClass('selected');
				$(this).children('div').addClass('unselected');
				//$(this).empty();
			}
		});		

		$('.send').click(function(){

			var qunfa_num = parseInt($('.saleMsgNum').html());
			if(qunfa_num=='0'){
				alert('您今日的群发次数为0次');
				return false;
			}

			var str = '';
			var i = 0;
			$('.shareMask').each(function(){
				var open = $(this).attr('open');
				if(open=='2'){
					var aid = $(this).attr('aid');
					str+=aid+',';
					i++;
				}
			});

			if(str == ''){
				alert('请选择数据');
				return false;
			}

			if(i>7){
				alert('推送消息不能超过7条');
				return false;
			}

			$('#pop').show();
			
			$.ajax({
				type:'post',
				url:'index.php?act=index&op=qunfa',
				data:{auction_all_id:str},
				dataType:'json',
				success:function(data){
					if(data.state == '0'){
						alert(data.error);
						return false;
					}
				}
			});
			
		});	
	});
</script>

</body>
</html>